//package com.xnyy.lottery.security;
//
//import com.xnyy.lottery.domain.entity.User;
//import com.xnyy.lottery.service.UserService;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.*;
//
///**
// * @description:
// * @auther: Administrator
// * @date: 2022/9/16 02:21
// */
//@Service
//public class UserDetailsServiceImpl implements UserDetailsService {
//    @Resource
//    private UserService userService;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        User user = userService.getByUsername(username);
//        if (user == null) {
//            throw new UsernameNotFoundException("用户名密码错误");
//        }
//        return createDetails(user);
//    }
//
//    private UserDetails createDetails(User user) {
//        return new LoginUser(user, this.getUserAuthority());
//    }
//
//    public List<SimpleGrantedAuthority> getUserAuthority() {
//        List<SimpleGrantedAuthority> authorities = new ArrayList<>();
//        authorities.add(new SimpleGrantedAuthority("ROLE_admin"));
//        return authorities;
//    }
//}
